﻿module Lhz.Page.DataManagement {
    class ApplicationManagement extends ManagementPage<Lhz.Entity.ServiceCenter.Application> {
        constructor() {
            super({
                targetName: "应用",
                serviceNo: "application",
                colModel: [
                    { title: "编号", dataIndx: "No", width: "200", align: "center" },
                    { title: "应用名称", dataIndx: "Name", width: "200", align: "center" },
                    { title: "描述", dataIndx: "Description", width: "400", align: "left" }
                ],
                detailPageUrl: "application-detail.html",
                width: 400,
                height: 200,
                getItemName: function (mp, item) {
                    return item.Name;
                },
                deleteCheck: function (mp, selectedItems, deleteCheckCallback) {
                    var pks: string[] = [];
                    for (var selectedItem of selectedItems) {
                        pks.push(selectedItem.Guid);
                    }
                    mp.sci.InvokeByInvokeArgument<string[]>({
                        serviceNo: "application",
                        operationNo: "deleteCheck",
                        arguments: [pks],
                        successCallback: function (result) {
                            var names: string[] = [];
                            for (var item of result.Result) {
                                for (var selectedItem of selectedItems) {
                                    if (item == selectedItem.Guid) {
                                        names.push(selectedItem.Name);
                                    }
                                }
                            }
                            deleteCheckCallback(names);
                        }
                    });
                }
            });
        }
    }
    $(function () {
        new ApplicationManagement();
    });
}
